package org.tru42.signal.lang;

import java.lang.reflect.InvocationTargetException;


/**
 * An ISink is a sink for exactly one ISignal.
 * @author Manuel Stahl
 *
 */
public interface ISink extends IConnectable {

	/**
	 * Called by the ISignal, when its value changes.
	 * @param args
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 */
	public void signalValueChanged(long timestamp, Object...args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException;

	/**
	 * Get the connected ISignal, null otherwise.
	 * @return the connected ISignal
	 */
	public ISignal getSignal();
	
	/**
	 * Get the ISinks name.
	 * @return name of the ISink
	 */
	public String getName();
	
	/**
	 * Get the ISinks owner.
	 * @return owner of the ISink
	 */
	public Object getOwner();
	
	/**
	 * Get the accepted types of the ISink. Connected ISignals must
	 * output at least the same number of types.
	 * @return accepted types of the ISink
	 */
	public Class<?>[] getTypes();
	
	/**
	 * Connect this ISink to an ISignal. The caller has to take care
	 * that also the ISignal gets connected to this ISink.
	 * @param signal ISignal to connect to.
	 * @throws ConnectException
	 */
	public void connectSignal(ISignal signal) throws ConnectException;
	
}
